LGF_Histogram_UDInt (FB / V3.0.1)


Author: Siemens Digital Industry

Short description

The histogram shows the frequency distribution of a sample by class. A class describes a value interval in which the individual frequencies are added together. After specifying the number of classes, the class width and the respective class center are calculated. The number of classes is limited to 15.

The distribution is represented as a rectangle around the class mean with the class width and the cumulated frequency as height.

Figure: Distribution

LGF_Histogram

WinCC-Control

To visualize the Boxplot, the Siemens Industry Online Support offers you a Net-Control, which you can use in conjunction with WinCC Runtime Professional. You can find the controls in the UserFiles folder of this library.

Figure: .Net Control "Histogram"

LGF_Histogram - WinCC .NET Control


Block Interface

LGF_Histogram_UDInt (FB)
Bool  execute error  Bool
    
UInt  numberOfClasses status  Word
    
   subfunctionStatus  Word
    
   histValues  Array[0..1, 0..#CLASSES_COUNTER_UP_LIMIT] of LReal
    
   axis  Array[0..3] of LReal
    
   classWidth  LReal
    
Array[*] of UDInt  values  Array[*] of UDInt
       
   

Input parameter

IdentifierData typeDefault valueDescription
executeBoolFALSEActivation of the calculation with each positive edge.
numberOfClassesUInt0Number of desired classes.

Output parameter

IdentifierData typeDescription
errorBoolFALSE: No error
TRUE: An error occurred during the execution of the FB
statusWord16#0000-16#7FFF: Status of the FB
16#8000-16#FFFF: Error identification (see following Table)
subfunctionStatusWordStatus or return value of called FB's, FC's and system blocks
histValuesArray[0..1, 0..#CLASSES_COUNTER_UP_LIMIT] of LRealOutputs the calculated values in a two-dimensional array.
• `histValues[0,0..14]` displays the relative frequency of the individual classes.
• `histValues[1,0..14]` displays the class centers.
• If fewer than 15 classes are desired, the array elements that are not required are output with 0.
axisArray[0..3] of LRealSpecifies the axis values:
• Lower X axis value
• Upper X axis value
• Lower Y axis value
• Upper Y axis value
classWidthLRealReturns the calculated class width.

In/Out parameter

IdentifierData typeDescription
valuesArray[*] of UDIntThe array containing the data series that is to be used for the calculation

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_EXECUTION_FINISHED
Status: Execution finished without errors
16#7000STATUS_NO_CALL
Status: No call of FB. The block waits for activation through the parameter `enable`.
16#7001STATUS_FIRST_CALL
Status: First call of FB after enabling
16#8600ERR_SHELL_SORT
Error: Error in command `LGF_ShellSort_UDInt`. Check `subFunctionStatus` code
16#9101ERR_WRONG_NO_CLASSES
Error: Incorrect number of classes. Give the parameter `numberOfClasses` a valid value (1 to 15).

Functional description

The block sorts the transferred data and calculates the general class width using the transferred class count and data range. The block then counts the values that lie within a class. In order to draw a histogram, the block also calculates the necessary X and Y coordinates.

The elements of the passed array values are sorted in ascending order by the block. The LGF_Shellsort_UDInt block is used for sorting.

The number of classes can be specified using the following rule of thumb:

Number~of~classes = \sqrt{number~of~elements}

e.g. 100 values --> Number~of~classes = \sqrt{100} = 10

Formulas

The block uses the following formula to calculate the class width:

classWidth = \frac{max - min}{Number~of~classes}

Change log

Version & DateChange description
01.00.00Siemens Industry Online Support
23.11.2018First released version
02.00.00Simatic Systems Support
06.11.2019Code refactoring, comments added
03.00.00Simatic Systems Support
23.04.2020Set version to V3.0.0, harmonize the version of the whole library
03.00.01Simatic Systems Support
06.04.2021Insert documentation